<template>
  <div>
    <el-table :border="false" :data="tableList" class="new-table-style">
      <el-table-column align="left" label="签约方类型" prop="partnerName">
        <template slot-scope="scope">
          <span v-if="scope.row.partnerType == 1">企业</span>
          <span v-if="scope.row.partnerType == 2">个人</span>
        </template>
      </el-table-column>
      <el-table-column align="center" label="签约方名称" prop="partnerName"></el-table-column>
      <el-table-column align="center" label="签约方简称" prop="partnerShortName"></el-table-column>
      <el-table-column align="center" label="对方负责人" prop="partnerManager"></el-table-column>
      <el-table-column align="center" label="负责人手机号" prop="mobile"></el-table-column>
      <el-table-column align="center" label="银行名称" prop="paymentBank"></el-table-column>
      <el-table-column align="center" label="银行账号" prop="paymentAccount"></el-table-column>
      <el-table-column v-if="isEdit" align="center" fixed="right" label="操作" width="80">
        <template slot-scope="scope">
          <el-button icon="el-icon-edit" class="normal-btn" size="mini" type="text" @click="editItem(scope.row)"></el-button>
          <el-button icon="el-icon-delete" class="normal-btn color-red" size="mini" type="text" @click="deleteItem(scope.$index)"></el-button>
        </template>
      </el-table-column>
    </el-table>

    <el-dialog title="签约方" :visible.sync="dialogShow" width="1100px" :close-on-click-modal="false" :close-on-press-escape="false">
      <form-common :filed-list="signFieldList" ref="infoForm" :formObj="signModel"></form-common>
      <div slot="footer" class="dialog-footer">
        <el-button @click="dialogShow = false" class="el-button-reset">取 消</el-button>
        <el-button type="primary" @click="confirmFn">确 认</el-button>
      </div>
    </el-dialog>
  </div>
</template>
<script>
  import formCommon from '@g/components/form/formCommon.vue';
  import { signFieldList } from '../form.js';
  import { guid, setFiledVal } from '@/common/js/utils';
  import Bus from '@js/bus.js';
  import { askDialog } from '@/pages/limit/assets/util';

  export default {
    props: {
      tableList: {
        type: Array,
        default: () => {
          return [];
        },
      },
      isEdit: {
        type: Boolean,
        default: true,
      },
    },

    data() {
      return {
        dialogShow: false,
        signModel: {},
        signFieldList: signFieldList,
      };
    },

    methods: {
      async init() {
        this.dialogShow = true
        await this.$nextTick(() => {});
        this.$refs.infoForm.clearValidateForm();
      },

      confirmFn() {
        let model = this.$refs.infoForm.validateForm();
        if (!model) return;

        this.dialogShow = false;
        this.$emit('confirmAddItem', model);
      },

      async editItem(item) {
        this.dialogShow = true
        let row = this.lodash.cloneDeep(item);
        this.signModel = row
      },

      deleteItem(index) {
        askDialog('确认删除？', async () => {
          this.$emit('deleteItem', index);
        });
      },
    },

    created() {},

    components: { formCommon },
  };
</script>
<style lang="scss" scoped></style>
